package com.hertz.alarm.baseTest;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

import org.databene.contiperf.junit.ContiPerfRule;
import org.junit.Rule;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.hertz.alarm.init.InitNbaTeam;
import com.hertz.alarm.service.FetchNbaData;
import com.hertz.alarm.service.IrisNbaAlarmService;
import com.hertz.alarm.service.IrisUserService;
import com.hertz.alarm.service.MatchNbaService;
import com.hertz.alarm.service.SystemTriggers;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:applicationContext.xml"})
public class Base extends AbstractJUnit4SpringContextTests{
	public Logger logger = LoggerFactory.getLogger(Base.class);
	@Resource
	public FetchNbaData fetchNbaData;
	@Resource
	public MatchNbaService matchNbaService;
	@Resource
	public InitNbaTeam initNbaTeam;
	@Resource
	public SystemTriggers systemTriggers;
	@Resource
	public IrisUserService irisUserService;
	@Resource
	public IrisNbaAlarmService irisNbaAlarmService;
	@Rule
	public ContiPerfRule i = new ContiPerfRule();
	
	
//	public Logger logger = LoggerFactory.getLogger(Base.class);
	
	@PostConstruct 
	protected void init(){
		
	}
	
	protected void printCacheError(Logger logger,Exception e) throws RuntimeException{
		printCacheError(logger,e,true);
	}
	
	protected void printCacheError(Logger logger,Exception e,boolean needThrows) throws RuntimeException{
		e.printStackTrace();
		logger.error("CacheError :{}",e.getMessage());
		if(needThrows)
			throw new RuntimeException(e);
	}
}
